package com.lc202309;

/**
 * Description:
 *
 * @Create 2023/8/30 23:29
 * @Version 1.0
 */
public class Solution28 {
    public int strStr(String haystack, String needle) {
        int length = needle.length();
        for (int i = 0; i < haystack.length(); i++) {
            for (int j = i; j < haystack.length() && j - i < length; j++) {
                if (haystack.charAt(j) != needle.charAt(j - i)) {
                    break;
                }
                if (j - i + 1 == length) {
                    return i;
                }
            }
        }
        return -1;
    }
}
